package com.tgr.shortLink.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.tgr.shortLink.project.common.convention.result.Result;
import com.tgr.shortLink.project.common.convention.result.Results;
import com.tgr.shortLink.project.dto.req.*;
import com.tgr.shortLink.project.dto.resp.LinkPageRespDTO;
import com.tgr.shortLink.project.dto.resp.RecycleBinPageRespDTO;
import com.tgr.shortLink.project.service.RecycleBinService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 描述：回收站功能控制层
 * 作者：小陶不慌张
 * 文件：RecycleBinController
 * 日期：2024/1/23 12:07
 */
@RestController
@RequiredArgsConstructor
public class RecycleBinController {
    private final RecycleBinService recycleBinService;

    @PostMapping("/api/short-link/v1/recycle-bin/save")
    public Result<Void> saveBin(@RequestBody RecycleBinSaveReqDTO requestParam){
        recycleBinService.saveBin(requestParam);
        return Results.success();
    }
    /**
     * 分页查询回收站
     * @param requestParam
     * @return
     */
    @GetMapping("/api/short-link/v1/recycle-bin/page")
    public Result<IPage<RecycleBinPageRespDTO>> pageBin(RecycleBinPageReqDTO requestParam){
        return Results.success(recycleBinService.pageBin(requestParam));
    }

    @PostMapping("/api/short-link/v1/recycle-bin/recover")
    public Result<Void> recoverBin(@RequestBody RecycleBinRecoverReqDTO requestParam){
        recycleBinService.recoverBin(requestParam);
        return Results.success();
    }

    @PostMapping("/api/short-link/v1/recycle-bin/remove")
    private Result<Void> removeBin(@RequestBody RecycleBinRemoveReqDTO requestParam){
        recycleBinService.removeBin(requestParam);
        return Results.success();
    }

}
